package com.inno.subject.controller.controller;

import com.inno.subject.common.annotiation.Log;
import com.inno.subject.common.context.LoginUserContext;
import com.inno.subject.common.entity.CommonReturnType;
import com.inno.subject.controller.convert.SmartQADTOConverter;
import com.inno.subject.controller.dto.SmartQADTO;
import com.inno.subject.domain.entity.SmartQABO;
import com.inno.subject.domain.service.SmartQADomainService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 智能问答
 * @author sean
 */
@RestController
@RequestMapping("/subject/qa")
public class SmartQAController {
    @Resource
    private SmartQADomainService smartQADomainService;

    @PostMapping("/submit")
    @Log(operationType = "智能问答")
    public CommonReturnType<Void> submit(@RequestBody SmartQADTO smartQADTO){
        smartQADTO.setCurrentUser(LoginUserContext.getUserId());
        SmartQABO smartQABO = SmartQADTOConverter.INSTANCE.convertDTOToBO(smartQADTO);
        smartQADomainService.submit(smartQABO);
        return CommonReturnType.success();
    }
}
